home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / Shaders / RCShaders / RCGlow.sl < prev    next >
Encoding:
Text File  |  1995-03-22  |  668 b   |  26 lines

  1. /* Listing 16.26  Shader mapping object-space coordinates to colors*/
  2. /*
  3.  * glow(): a shader for providing a centered "glow" in a sphere 
  4.  */
  5.  
  6. surface
  7. RCGlow( float    attenuation = 2 )
  8. {
  9.    point NN = normalize(N);
  10.    point II = normalize(I);
  11.    float falloff = II.NN;    /* Direct incidence has cosine closer to 1.*/
  12.  
  13.    if (falloff < 0) 
  14.    {  /* Back of sphere only */
  15.       /* Normalize falloff by lengths of I and N */
  16.       falloff = falloff * falloff / (II.II * NN.NN) ;
  17.       falloff = pow(falloff, attenuation);
  18.       Ci = Cs * falloff;
  19.       Oi = falloff;
  20.    } 
  21.    else
  22.    {  Oi = 0;
  23.       Ci = 0; /* wave added this line to avoid old bug in rendrib... */
  24.    }
  25. }
  26.